//package com.ruoyi.basic.controller;
package com.ruoyi.web.controller.basic;
import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basic.domain.KaoqinList;
import com.ruoyi.basic.service.IKaoqinListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考勤记录Controller
 *
 * @author hyh
 * @date 2021-04-13
 */
@RestController
@RequestMapping("/basic/record")
public class KaoqinListController extends BaseController
{
    @Autowired
    private IKaoqinListService kaoqinListService;

    /**
     * 查询考勤记录列表
     */
    @PreAuthorize("@ss.hasPermi('basic:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(KaoqinList kaoqinList)
    {
        startPage();
        //获取用戶名
        String username = SecurityUtils.getUsername();
        List<KaoqinList> list = kaoqinListService.selectKaoqinListList(kaoqinList);
        return getDataTable(list);
    }

    /**
     * 导出考勤记录列表
     */
    @PreAuthorize("@ss.hasPermi('basic:record:export')")
    @Log(title = "考勤记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(KaoqinList kaoqinList)
    {
        //获取用戶名
        String username = SecurityUtils.getUsername();
        List<KaoqinList> list = kaoqinListService.selectKaoqinListList(kaoqinList);
        ExcelUtil<KaoqinList> util = new ExcelUtil<KaoqinList>(KaoqinList.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取考勤记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(kaoqinListService.selectKaoqinListById(id));
    }

    /**
     * 新增考勤记录
     */
    @PreAuthorize("@ss.hasPermi('basic:record:add')")
    @Log(title = "考勤记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KaoqinList kaoqinList)
    {
        return toAjax(kaoqinListService.insertKaoqinList(kaoqinList));
    }

    /**
     * 修改考勤记录
     */
    @PreAuthorize("@ss.hasPermi('basic:record:edit')")
    @Log(title = "考勤记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KaoqinList kaoqinList)
    {
        return toAjax(kaoqinListService.updateKaoqinList(kaoqinList));
    }

    /**
     * 删除考勤记录
     */
    @PreAuthorize("@ss.hasPermi('basic:record:remove')")
    @Log(title = "考勤记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kaoqinListService.deleteKaoqinListByIds(ids));
    }
}